﻿using System;
using System.Data;
using Model.Data;
using Model;
using DataAccess;
using BusinessLogic.BusinessRules;


namespace BusinessLogic.ClassFactory
{
    /// <summary>
    /// ServerVariableFactory 的摘要说明。
    /// </summary>
    public class ServerVariableFactory : BaseFactory
    {
        public ServerVariableFactory()
            : base()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public ServerVariableFactory(DBManager l_DBManager)
            : base(l_DBManager)
        {
        }
        public ServerVariable NewInstance()
        {
            ServerVariableAccess l_Access = new ServerVariableAccess(m_Manager);
            ServerVariable objServerVariable = new ServerVariable(this.m_Manager, l_Access);
            objServerVariable.NewDataSet();
            objServerVariable.SelectRow(0);
            return objServerVariable;
        }

        public ServerVariable CreatorBySql(string Sql)
        {
            ServerVariableAccess l_Access = new ServerVariableAccess(m_Manager);
            ServerVariable objServerVariable = new ServerVariable(this.m_Manager, l_Access);
            DataSet l_ds = new ServerVariableData();
            if (l_Access.QueryBySql(ref l_ds, Sql) < 1)
            {
                return null;
            }
            objServerVariable.SetDataSet(l_ds);
            objServerVariable.SelectRow(0);
            return objServerVariable;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="intSVID"></param>
        /// <returns></returns>
        public ServerVariable Creator(int intSVID)
        {
            ServerVariableAccess l_Access = new ServerVariableAccess(m_Manager);
            ServerVariable objServerVariable = new ServerVariable(this.m_Manager, l_Access);
            DataSet l_ds = new ServerVariableData();
            if (l_Access.QueryByID(ref l_ds, intSVID) < 1)
            {
                return null;
            }
            objServerVariable.SetDataSet(l_ds);
            objServerVariable.SelectRow(0);
            return objServerVariable;
        }

        public ServerVariable Creator()
        {
            ServerVariableAccess l_Access = new ServerVariableAccess(m_Manager);
            ServerVariable objServerVariable = new ServerVariable(this.m_Manager, l_Access);
            DataSet l_ds = new ServerVariableData();
            if (l_Access.QueryAll(ref l_ds) < 1)
            {
                return null;

            }
            objServerVariable.SetDataSet(l_ds);
            objServerVariable.SelectRow(0);
            return objServerVariable;
        }

    }
}
